$(document).ready(function(){
    $("table.tableStyle tr.clickable.current").each(function(){
        var val = $(this).attr('value');
        $(this).fancybox({
            type: 'ajax',
            width: 400,
            autoSize: false,
            autoHeight: true,
            href: getBaseURL()+"feedback/current_feedback/viewFeedback?feedback_id="+val
        });
    });
    
    $("table.tableStyle tr.clickable.archived").each(function(){
        var val = $(this).attr('value');
        $(this).fancybox({
            type: 'ajax',
            width: 400,
            autoSize: false,
            autoHeight: true,
            href: getBaseURL()+"feedback/archived_feedback/viewFeedback?feedback_id="+val
        });
    });

    $('#datePickerText').monthpicker({
        openOnFocus: false,
        pattern: 'yyyy/mm'
    }).bind('monthpicker-hide',function(){
        if ($('#datePickerText').val()){
            window.location = getBaseURL()+"feedback/archived_feedback/showMonth/"+$('#datePickerText').val();
        }
    });
        
    $('#datePicker').click(function(){
        $('#datePickerText').monthpicker('show');
    });
    
    
});

function responsePopUp(me){
    $(me).fancybox({
        type: 'ajax',
        width: 400,
        autoSize: false,
        autoHeight: true,
        href: getBaseURL()+"feedback/current_feedback/viewFeedback?feedback_id="+$(this).val()
    });
}

function discard(value){
    var feedback_id = value;
    $("#feedback_response").text(" ");//Why doing this works I have no idea...
    if (confirm("Are you sure you wish to discard this feedback?")){
        $.post(getBaseURL()+"feedback/current_feedback/discardFeedback/", 
            {feedback_id: feedback_id},
            function(data){
                location.reload();
            }
        );
    }
}